package chpt03;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

public class PersonV1Demo {
	//main方法演示了，通过不同类的对象之间的交互实现复杂的功能
	public static void main(String[] args) {
		PersonV1 p1 = new PersonV1();
		p1.id = 1;
		p1.name = "张三";
		p1.tel = "181xxxx";
		p1.date = LocalDate.of(2004, 2, 29);
		//p1.date = LocalDate.of(2004, 2, 30);
		p1.show();
		String x = p1.date.isLeapYear()?"是闰年":"不是闰年";
		System.out.println(p1.date.toString()+ x);
		System.out.println(p1.date+"是"+p1.date.getDayOfWeek());
		LocalDate now = LocalDate.now(); //获得当前日期
		long day = p1.date.until(now, ChronoUnit.DAYS);
		long years = p1.date.until(now, ChronoUnit.YEARS);
		System.out.println("两个日期之间相差:"+day+"天或"+ years+"年");
	}
}
